#!/bin/bash
#

KEYWORDS=mongo

NAMESPACE=spark-cluster

APP=mongo

KUBESERVER='172.16.1.27:8080'

PODS=$(kubectl --server=${KUBESERVER} get pods --namespace=${NAMESPACE} | grep -i ${KEYWORDS} | cut -d' ' -f1 | head -1)

if [ ! -z $PODS ];then

    kubectl --server=${KUBESERVER} exec -it $PODS $APP --namespace=${NAMESPACE}

else
    echo; echo "Didn't find relevant containers, please check whether the specified the correct namespace"; echo
    exit 2
fi


